1. Field of the Invention
The present invention relates generally to host adapters that couple two I/O buses, and more particularly to using a scatter/gather list in transferring data over a host I/O bus.
2. Description of Related Art
A host adapter 150 (FIG. 1A) connects I/O devices, such as data storage devices, on an I/O bus 180 to a host I/O bus 170. Examples of I/O devices are magnetic disk drives that typically are on a SCSI bus or alternatively a UDMA bus. Host system 100 typically has a PCI bus, as host I/O bus 170.
In more general terms, host adapter 150 typically provides a connection between two different I/O buses 180 and 170. Host adapter 150 also provides functions associated with data transfer between host system 100 and the I/O devices on bus 180.
A host adapter driver 120 builds a hardware I/O control block that is provided to host adapter 150. The hardware I/O control block provides information to host adapter 150 on the area in host memory 115 that is to be used in the data transfer and a command that is to be transferred to the target I/O device.
The area in host memory 115 allocated for a particular data transfer is often fragmented into a plurality of segments, for example, segments 116, 117, and 118. Host adapter driver 120 generates a scatter/gather list 130A that identifies each of the plurality of segments. Each of elements 130_1A to 130_nA in scatter/gather list 130A specifies an address and length of one segment. For example, element 130_1A specifies segment 116, which is at address x1 and has a length y1. Typically, as shown in FIG. 1A, elements 130_1A to 130_nA are contiguous in memory 115.
The information in the hardware I/O control block contains the address of element 130_1A in list 130A. In the embodiment of FIG. 1A, the hardware I/O control block also includes a list length variable 135A that is the number of elements in list 130A. Memory is allocated both in host memory 115 and in memory of host adapter 150 for length list variable 135A, which can be several bytes in size, and for scatter/gather list 130A. Host adapter 150 decrements variable 135A as host adapter 150 works down scatter/gather list 130A. When variable 135A is decremented to zero, host adapter 150 recognizes that there are no more elements in list 130A. This event normally coincides with the end-of-the data transfer.
The inefficiencies and limitations associated with list length variable 135A have been recognized. In the embodiment of FIG. 1B, each element of scatter/gather list 130B includes a single end list flag bit. For all elements of list 130B except the last element, the end list flag bit has a value of zero. For last element 130_nB, the end list flag bit has a value of one.
Hence, host adapter 150 tests the end list flag bit as each element of list 130B is processed. When the set end list flag bit is detected, host adapter 150 knows that the last element in scatter/gather list 130B is being processed.
The scheme has several advantages. No memory is allocated for list length variable 135A (FIG. 1A). Host driver 120 does not have to calculate list length variable 135A, and host adapter 150 does not have to manage list length variable 135A during the data transfer. The size of list 130B is not limited by the size of list length variable 135A.
While the scheme associated with FIG. 1B has many advantages, list 130B must still be in contiguous memory locations. Allocation of a large contiguous memory area in memory 115 can be problematic. Thus, it has been recognized that it is desirable to break a scatter/gather list into small discontiguous sections.
The SCSI standards committee has proposed breaking the scatter/gather list into smaller linked sections. The proposed technique is illustrated in FIG. 1C. Scatter/gather list 130C is broken into three sections 140, 141, and 142, in this example. Each of sections 140, 141, and 142 has (n+1) elements. This technique still requires a list length variable 135C that has a value that is the total length of scatter/gather list 130C. A second variable, a section length variable 136, is used to specify the number of elements in each of sections 140 to 142.
With this technique, host adapter 150 has to maintain both variables 135C and 136, and decrement each. When section length variable 136 reaches zero, the last element in a section is being processed. The address in the last element is not an address for a data segment, but rather the address of the next section of the scatter/gather list. When list length variable 135C reaches zero, host adapter 150 knows that the entire scatter/gather list 130C has been processed. While this technique allows the use of larger scatter/gather lists by eliminating the requirement that the entire scatter/gather list be in contiguous memory locations, the technique requires additional storage for second variable 136, and the total size of first variable 135C limits the total number of elements in scatter/gather list 130C. Also, the technique places additional processing requirements on host adapter 150. Thus, sections are useful only when both the additional storage required and the additional processing capability are available.